<?php
	// V�rification si l'email/login existe d�j�
	function model_quick_check_email( $bdd, $email_or_login)
	{
		$req= $bdd->prepare( 'SELECT * FROM users WHERE  user_login=:email_or_login OR user_email=:email_or_login');
		
		// V�rifie qu'il n'y a pas eu d'erreurs dans la requ�te
		if( !$req->execute(	array( 'email_or_login' => $email_or_login))) return 0;
		
		$results= $req->fetch( PDO::FETCH_OBJ);
		
		// Si on a trouv� l'email/login dans la base de donn�e on retourne 1
		return ( empty( $results)) ? 0 : 1;
	}
	// R�cup�re le informations( nom, mdp,...) � partir de l'id de son id
	function model_quick_insert_account_by_mail( $bdd, $email, $password)
	{
		$req= $bdd->prepare('INSERT INTO users ( `user_email`, `user_password`) VALUES ( :user_email, :user_password)');
		
		$req->execute(	array( 'user_email' => $email, 'user_password' => $password));
		
		return $bdd->lastInsertId();
	}
	function model_quick_insert_account_by_login( $bdd, $login, $password)
	{
		$req= $bdd->prepare('INSERT INTO users ( `user_login`, `user_password`) VALUES ( :user_login, :user_password)');
		
		$req->execute(	array( 'user_login' => $login, 'user_password' => $password));

		return $bdd->lastInsertId();
	}
	
	// R�cup�re le informations( nom, mdp,...) � partir de l'id
	function model_quick_user_informations( $bdd, $id_user)
	{
		$id_user= $bdd->quote( $id_user);
	
		$results= $bdd->query( 'SELECT * FROM `users` WHERE `id_user`='.$id_user);
	
		return $results->fetch( PDO::FETCH_OBJ);
	}
?>